<!doctype html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<meta name="format-detection" content="telephone=no" />
	<title>首页</title>
	<link rel="stylesheet" type="text/css" href="../c/aui.css" />
	<link rel="stylesheet" type="text/css" href="../c/fang.css" />
</head>

<body>
	<script id="sx-list-field" type="text/x-dot-template">
	<div class="f-type" >
		{{ for(var i=0; i < field.length; i++) { }}
		<div class="a" id="name_{{= field[i].id }}">
			<div class="l {{? field[i].id==2 }} {{? !v.name_2}}b{{?}} {{??}}b{{?}}"  tapmode onclick="name(1,{{= field[i].id }})">全部{{= field[i].title}}</div>
			<div class="r">
				<ul>
					{{ for(var i_s=0; i_s < field[i].name.length; i_s++) { }}
					<li tapmode onclick="name(this,{{= field[i].id }})" {{? v.name_2==field[i].name[i_s].id}}class="b"{{?}} data-id="{{= field[i].name[i_s].id}}">{{= field[i].name[i_s].title}}</li>
					{{ } }}
				</ul>
			</div>
		</div>
		{{ } }}
	</div>
	</script>
	<div id="sx-view-field"></div>
	<div class="f-list">
		<div class="f-ul" id="sx-view"></div>
		<script id="sx-list" type="text/x-dot-template">
		{{ for(var i=0,it=it.data; i < it.length; i++) { }}
		<div class="li"  tapmode onclick="_url({url:'fang_view_win',aid:{{= it[i].id }}},'fang_view_win')">
			<div class="img" style="height:{{= (li_w/3)+50 }}px">
				<img suxiangw-src="{{= _img(it[i].img,(li_w/3)+50,-1)}}" src="../i/loading_b.png" />
				{{? it[i].quanji == 1 }}
				<span class="a1">{{= it[i].url_len }}集全</span>
				{{?? it[i].quanji == 2 }}
				<span class="a1">更新至{{= it[i].url_len }}集</span>
				{{?? it[i].type == 1}}
				<span class="a1">电影</span>
				{{?}}
			</div>
			<div class="content">
				<div class="title aui-ellipsis-1">{{= it[i].title }}</div>
			</div>
		</div>
		{{ } }}
		</script>
	</div>
</body>
<script type="text/javascript" src="../j/api.js"></script>
<script src="../j/jquery-3.3.1.min.js"></script>
<script type="text/javascript">
	var li_w = $('.f-list').width(),v=[],NVNavigationBar;
	apiready = function() {
		urls();
		NVNavigationBar = api.require('NVNavigationBar');
		v = api.pageParam;
		if(v.type && v.type!=0){
			url = 'fang/lists/limit/12/type/'+v.type;
			field = _getPrefs('_config').fang[v.type].field;
			type = _getPrefs('_config').fang;
			var evalData = doT.template($api.html($api.byId('sx-list-field')));
			$api.html($api.byId('sx-view-field'), evalData());
		}else{
			if(v.text){
				url = 'fang/lists/limit/12/title/'+v.text;
			}else{
				url = 'fang/lists/limit/12/tuijian/1';
			}
		}
		// console.log(JSON.stringify(field))

		// console.log(url)
		_list({url:url});
		// _shangla(function(ret,err){
		// 	_list({url:url});
		// },1)
		// 监听滚动
		api.addEventListener({
			name : 'scrolltobottom',
			extra : {threshold : api.winHeight/2}
		}, function(ret, err) {
			if (heigutgao == 1) {
				pagenum += 1
				_list({url:url,page:pagenum});
			}
		});
	};
	// 筛选字段更新
	function name(_this,name_id){
		$('#name_'+name_id+' .b').removeClass('b');
		if(_this != 1){
			$(_this).addClass('b');
		}else{
			$('#name_'+name_id+' .l').addClass('b');
		}
		var name_1 = $('#name_1 li.b').data('id');
		name_1 = name_1 ? name_1 : 0;
		var name_2 = $('#name_2 li.b').data('id');
		name_2 = name_2 ? name_2 : 0;
		var name_3 = $('#name_3 li.b').data('id');
		name_3 = name_3 ? name_3 : 0;

		url = 'fang/lists/limit/12/type/'+v.type+ '/name_1/'+name_1+'/name_2/'+name_2+'/name_3/'+name_3
		// console.log(url);
		_list({url:url});
	}
</script>

</html>
